Expand description
§Rust Adwaita bindings
This library contains safe Rust bindings for Adwaita, a library that offers building blocks for modern GNOME applications.
See also
- GTK 4 Rust bindings documentation
- Libadwaita documentation
- gtk-rs project overview
- Report bindings related issues
- Report upstream libadwaita issues
§Example
Adwaita needs to be initialized before use. This can be done by either:
- using
adw::Application
instead ofgtk::Application
, or by - calling
init
onstartup
.
The libadwaita
crate is usually renamed to adw
. You can
do this globally in your Cargo.toml
file:
[dependencies.adw]
package = "libadwaita"
version = "0.x.y"
use adw::prelude::*;
use adw::{ActionRow, Application, ApplicationWindow, HeaderBar};
use gtk::{Box, ListBox, Orientation, SelectionMode};
fn main() {
let application = Application::builder()
.application_id("com.example.FirstAdwaitaApp")
.build();
application.connect_activate(|app| {
// ActionRows are only available in Adwaita
let row = ActionRow::builder()
.activatable(true)
.title("Click me")
.build();
row.connect_activated(|_| {
eprintln!("Clicked!");
});
let list = ListBox::builder()
.margin_top(32)
.margin_end(32)
.margin_bottom(32)
.margin_start(32)
.selection_mode(SelectionMode::None)
// makes the list look nicer
.css_classes(vec![String::from("boxed-list")])
.build();
list.append(&row);
// Combine the content in a box
let content = Box::new(Orientation::Vertical, 0);
// Adwaitas' ApplicationWindow does not include a HeaderBar
content.append(&HeaderBar::new());
content.append(&list);
let window = ApplicationWindow::builder()
.application(app)
.title("First App")
.default_width(350)
// add content to window
.content(&content)
.build();
window.present();
});
application.run();
}
Re-exports§
Modules§
Structs§
- About
Dialog v1_5
GLib type: GObject with reference counted clone semantics. - About
Window Deprecated v1_2
GLib type: GObject with reference counted clone semantics. - GLib type: GObject with reference counted clone semantics.
- Alert
Dialog v1_5
GLib type: GObject with reference counted clone semantics. - GLib type: GObject with reference counted clone semantics.
- GLib type: GObject with reference counted clone semantics.
- GLib type: GObject with reference counted clone semantics.
- GLib type: GObject with reference counted clone semantics.
- GLib type: GObject with reference counted clone semantics.
- Banner
v1_3
GLib type: GObject with reference counted clone semantics. - GLib type: GObject with reference counted clone semantics.
- Bottom
Sheet v1_6
GLib type: GObject with reference counted clone semantics. - Breakpoint
v1_4
GLib type: GObject with reference counted clone semantics. - Breakpoint
Bin v1_4
GLib type: GObject with reference counted clone semantics. - GLib type: Boxed type with copy-on-clone semantics.
- GLib type: GObject with reference counted clone semantics.
- Button
Row v1_6
GLib type: GObject with reference counted clone semantics. - GLib type: GObject with reference counted clone semantics.
- GLib type: GObject with reference counted clone semantics.
- GLib type: GObject with reference counted clone semantics.
- GLib type: GObject with reference counted clone semantics.
- GLib type: GObject with reference counted clone semantics.
- GLib type: GObject with reference counted clone semantics.
- GLib type: GObject with reference counted clone semantics.
- GLib type: GObject with reference counted clone semantics.
- Dialog
v1_5
GLib type: GObject with reference counted clone semantics. - Entry
Row v1_2
GLib type: GObject with reference counted clone semantics. - GLib type: GObject with reference counted clone semantics.
- GLib type: GObject with reference counted clone semantics.
- GLib type: GObject with reference counted clone semantics.
- Flap
Deprecated GLib type: GObject with reference counted clone semantics. - GLib type: GObject with reference counted clone semantics.
- GLib type: GObject with reference counted clone semantics.
- Layout
v1_6
GLib type: GObject with reference counted clone semantics. - Layout
Slot v1_6
GLib type: GObject with reference counted clone semantics. - Leaflet
Deprecated GLib type: GObject with reference counted clone semantics. - Leaflet
Page Deprecated GLib type: GObject with reference counted clone semantics. - Message
Dialog Deprecated v1_2
GLib type: GObject with reference counted clone semantics. - Multi
Layout View v1_6
GLib type: GObject with reference counted clone semantics. - Navigation
Page v1_4
GLib type: GObject with reference counted clone semantics. - GLib type: GObject with reference counted clone semantics.
- Navigation
View v1_4
GLib type: GObject with reference counted clone semantics. - Overlay
Split View v1_4
GLib type: GObject with reference counted clone semantics. - Password
Entry Row v1_2
GLib type: GObject with reference counted clone semantics. - GLib type: GObject with reference counted clone semantics.
- GLib type: GObject with reference counted clone semantics.
- GLib type: GObject with reference counted clone semantics.
- GLib type: GObject with reference counted clone semantics.
- Preferences
Window Deprecated GLib type: GObject with reference counted clone semantics. - GLib type: GObject with reference counted clone semantics.
- SpinRow
v1_4
GLib type: GObject with reference counted clone semantics. - Spinner
v1_6
GLib type: GObject with reference counted clone semantics. - Spinner
Paintable v1_6
GLib type: GObject with reference counted clone semantics. - GLib type: GObject with reference counted clone semantics.
- GLib type: GObject with reference counted clone semantics.
- GLib type: Shared boxed type with reference counted clone semantics.
- Squeezer
Deprecated GLib type: GObject with reference counted clone semantics. - Squeezer
Page Deprecated GLib type: GObject with reference counted clone semantics. - GLib type: GObject with reference counted clone semantics.
- GLib type: GObject with reference counted clone semantics.
- GLib type: GObject with reference counted clone semantics.
- GLib type: GObject with reference counted clone semantics.
- Switch
Row v1_4
GLib type: GObject with reference counted clone semantics. - GLib type: GObject with reference counted clone semantics.
- TabButton
v1_3
GLib type: GObject with reference counted clone semantics. - TabOverview
v1_3
GLib type: GObject with reference counted clone semantics. - GLib type: GObject with reference counted clone semantics.
- GLib type: GObject with reference counted clone semantics.
- TabView
Shortcuts v1_2
- GLib type: GObject with reference counted clone semantics.
- GLib type: GObject with reference counted clone semantics.
- GLib type: GObject with reference counted clone semantics.
- Toggle
v1_7
GLib type: GObject with reference counted clone semantics. - Toggle
Group v1_7
GLib type: GObject with reference counted clone semantics. - Toolbar
View v1_4
GLib type: GObject with reference counted clone semantics. - GLib type: GObject with reference counted clone semantics.
- GLib type: GObject with reference counted clone semantics.
- View
Stack Pages v1_4
GLib type: GObject with reference counted clone semantics. - GLib type: GObject with reference counted clone semantics.
- GLib type: GObject with reference counted clone semantics.
- View
Switcher Title Deprecated GLib type: GObject with reference counted clone semantics. - GLib type: GObject with reference counted clone semantics.
- GLib type: GObject with reference counted clone semantics.
- WrapBox
v1_7
GLib type: GObject with reference counted clone semantics. - Wrap
Layout v1_7
GLib type: GObject with reference counted clone semantics.
Enums§
- Accent
Color v1_6
- Flap
Fold Policy Deprecated - Flap
Transition Type Deprecated - Fold
Threshold Policy Deprecated - Justify
Mode v1_7
- Leaflet
Transition Type Deprecated - Length
Unit v1_4
- Pack
Direction v1_7
- Squeezer
Transition Type Deprecated - Toolbar
Style v1_4
- Wrap
Policy v1_7